export class PunchItem {
    constructor(date, startPunchDate, photoPunchDate, endPunchDate) {
        this.date = date;
        this.start_punch_date = startPunchDate;
        this.photo_punch_date = photoPunchDate;
        this.end_punch_date = endPunchDate;
    }
}

export class LocalPunchData {
    constructor(code, token, sendDate, punch) {
        this.code = code;
        this.token = token;
        this.send_date = sendDate;
        this.punch = punch;
    }

    /**
     * 添加打卡记录
     * @param {Object} punchItem - 打卡项对象
     * @param {string} punchItem.date - 打卡日期
     * @param {string} punchItem.start_punch_date - 开始打卡时间
     * @param {string} punchItem.photo_punch_date - 拍照打卡时间
     * @param {string} punchItem.end_punch_date - 结束打卡时间
     */
    addPunchItem(punchItem) {
        this.punch.push(new PunchItem(
            punchItem.date,
            punchItem.start_punch_date,
            punchItem.photo_punch_date,
            punchItem.end_punch_date
        ));
    }

    /**
     * 转换为JSON对象
     * @returns {Object} JSON格式的打卡数据
     */
    toJSON() {
        return {
            code: this.code,
            token: this.token,
            send_date: this.send_date,
            punch: this.punch
        };
    }
}